package com.up.upzl.biz.domain;

import java.util.List;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.ManyToOne;

import com.up.upzl.base.domain.BaseDomain;

import lombok.Getter;
import lombok.Setter;

/**
 * 后台用户
 * 
 * @author geeks
 *
 */
@Getter
@Setter
@Entity
public class SysAccount extends BaseDomain {

	private static final long serialVersionUID = -8547218434049214948L;

	/**
	 * 账号
	 */
	@Column(length = 32, unique = true)
	private String account;

	/**
	 * 用户名
	 */
	@Column(length = 32)
	private String name;

	/**
	 * 密码
	 */
	@Column(length = 64)
	private String password;
	
	/**
	 * 用户状态
	 */
	private AccountStatus accountStatus;
	
	public enum AccountStatus{
		禁用, 正常
	}

	/**
	 * 角色
	 */
	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "role_id")
	private SysRole sysRole;

	/**
	 * 城市
	 */
	@ManyToMany
	@JoinTable(name = "sys_account_city", joinColumns = @JoinColumn(name = "account_id"), inverseJoinColumns = @JoinColumn(name = "city_id"))
	private List<City> city;

}
